GBML manual / Screen

screen_mosaic

Turns the things you marked blocky (backgrounds, objects, and a room’s tiles) into big square blocks, a different size on each row if the look says so, so a picture can come into focus from the top down. look is one of the MOSAIC_ constants, strength (1 to 3) is how big the blocks are, and speed is how fast a moving look travels. MOSAIC_NONE turns it off. Give the optional last argument layer (ROOM_LAYER_MAIN, ROOM_LAYER_FRONT or ROOM_LAYER_BACK) to make only that one tile layer of the room blocky: screen_mosaic(MOSAIC_BLOCKS, 2, 0, ROOM_LAYER_FRONT) turns the Front layer into blocks and leaves the Main and Back layers sharp. With no layer the look reaches everything it always did.

Works differently on Game Boy - The Game Boy makes the picture you marked blocky in height only (each block repeats its top line), not in width; sprites and text stay sharp, and blocks cannot run together with a ripple, a floor or a road.

Works differently on Game Boy Color - The Game Boy Color makes the picture you marked blocky in height only (each block repeats its top line), not in width; sprites and text stay sharp.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

screen_mosaic(look, strength, speed, layer = ROOM_LAYER_ALL)

Arguments

NameType
lookmosaic_look
strengthint
speedreal
layerroom_layer (can be left out; then it is ROOM_LAYER_ALL)

Returns

Nothing.

Description

Turns a picture into big square blocks, as if it were drawn with huge pixels, and lets the size of the blocks be different on every row. A picture can come into focus from the top down, or turn into a mosaic of blocks that stay the same size from top to bottom, or glitch in stripes like a television that is going wrong.

A real capture, four pictures of the same pine forest at dusk with a striped lighthouse standing in it - first sharp, then with each of the three MOSAIC_ looks in turn at strength 2 (the forest in square blocks, blocky at the top and sharp at the bottom, and blocky stripes), the lighthouse sharp every timeA real capture, four pictures of the same pine forest at dusk with a striped lighthouse standing in it - first sharp, then with each of the three MOSAIC_ looks in turn at strength 2 (the forest in square blocks, blocky at the top and sharp at the bottom, and blocky stripes), the lighthouse sharp every time
A real capture, four pictures of the same pine forest at dusk with a striped lighthouse standing in it - first sharp, then with each of the three MOSAIC_ looks in turn at strength 2 (the forest in square blocks, blocky at the top and sharp at the bottom, and blocky stripes), the lighthouse sharp every time

The forest sharp first. Then each look at strength 2, standing still. The lighthouse is a sprite that is not marked, so it stays sharp. Real pictures from a Game Boy Advance ROM.

You give it three things:

Which look

LookWhat it isThe blocks at strength 1, 2 and 3
MOSAIC_BLOCKSblocks the same size on every row2, 4 and 8 pixels across
MOSAIC_DISSOLVEblocky at the top of the screen, sharp at the bottom; the line between them moves4, 8 and 16 pixels across at the top
MOSAIC_BANDSstripes 8 rows tall, a blocky one then a sharp one2, 4 and 8 pixels across in the blocky stripes

What it changes

It changes what you marked blocky, and only that:

Everything else stays sharp. A mosaic look on a screen with nothing marked changes nothing at all.

Each block is one pixel of the picture, made big: its color is the color of the pixel in the block's top left corner. A block is as tall as it is wide, and each row of the screen picks its own size, so MOSAIC_DISSOLVE can have blocks that shrink row by row.

One at a time

The console has just one block size, so there is at most one mosaic look at a time. Asking for a different look, or the same look at a different strength, replaces the first one and keeps the pattern where it was. Asking again for the same look and strength only changes the speed, so a Step event that asks every frame does not restart anything.

Call it once

You do not need to call it every frame. Call it once - when the room starts is a good time - and the look keeps going by itself. A look belongs to the screen, so there is nothing to remember and nothing to lose: the look ends by itself when a room is loaded (you change room, or restart the one you are in), so a new room that wants a pattern asks for its own.

Turning it off

screen_mosaic(MOSAIC_NONE, 0, 0);

This gives its slot back straight away, and every picture is sharp again. The last two numbers are ignored, but they have to be there.

Always destroy it, do not hide it. There is no way to hide a look, on purpose: something hidden would look gone but would still be using up one of the console's few row-by-row slots, and then the next effect you ask for would not appear and nothing would tell you why. Off always means the slot is free.

What it costs

A mosaic look uses one of the 8 row-by-row effects the console has, and no matrix and no sprite. A room change keeps two of the eight for itself, so there are six left for you, shared with everything else that works row by row: screen_backdrop, draw_sprite_ripple, sprite_warp and the others. You can see how many are in use on the debug screen: the line called H-BLANK.

The patterns live in the cartridge: a few hundred bytes each, and a call that names its look keeps only that one. The 160 rows the console reads are worked out into 2,560 bytes of memory. Measured on a real ROM, a look that stands still costs about 1 hundredth of a frame, and one that moves costs about 5 hundredths, because its rows are worked out again every frame it moves.

When there is no room

Ask for more than there is and the game does not skip it. A development build stops with a message that says how many slots there are and names every look that is holding one, so you know which one to turn off. A release build, which has no way to stop and show a message, draws everything sharp. It never half-works.

Example

pic = background_create(0, 0, ts_doc_dungeon);
background_blocky(pic, true);
screen_mosaic(MOSAIC_DISSOLVE, 3, 1);

A picture that starts out as big blocks and comes into focus from the bottom up in about three seconds. When it is all sharp, the dissolve turns round and the picture starts to go blocky again, so turn it off at the moment you want it to stop.

screen_mosaic(MOSAIC_BLOCKS, 2, 0);

Every marked background is drawn in blocks 4 pixels across. Asking again with MOSAIC_BLOCKS and the same strength changes nothing, because it is the same look.

To go back to the sharp picture, use screen_mosaic(MOSAIC_NONE, 0, 0) as shown above.

One tile layer

Give it a fourth number, the layer, and only that one tile layer of the room turns into blocks: ROOM_LAYER_MAIN, ROOM_LAYER_FRONT or ROOM_LAYER_BACK. The layer is marked blocky for you, and the other layers stay sharp. With no layer the call is the call it always was. A room that does not have that layer does nothing. Because the console has one block size, the look is still one look for the whole screen: if two layers are blocky they show the same look. In the Room Editor, the Effect of a tile layer (Blocks) writes this call for you and the canvas plays it live.

screen_mosaic(MOSAIC_BLOCKS, 2, 0, ROOM_LAYER_FRONT);

Turns the Front layer into blocks 4 pixels across, and leaves the Main and Back layers sharp.

On the GBA

Costs ONE of the console’s 8 row-by-row (H-Blank) effects for as long as the look is on, and no matrix and no sprite. A room change keeps two of the eight for itself, so six are left for you, shared with everything else that works row by row. The console has just ONE block size, so there is at most one mosaic look at a time: asking for a different look or strength replaces the first, and asking again for the same look and strength only changes the speed. It only changes what is marked blocky: the backgrounds you marked with background_blocky, the objects you marked with sprite_blocky (everything they draw, text too), and the tiles of a room whose Tile blocks (Room Properties) is not None. Everything else is drawn sharp. The console takes one pixel for each whole block, from the screen’s own rows: a block is as tall as it is wide, and a row picks its own size. The tables are in the cartridge (a few hundred bytes each; a call with a look written out keeps only that one), the 160 rows the console reads are worked out into 2,560 bytes of its big, slow memory (EWRAM), and again every frame a moving look moves (about 5 hundredths of a frame each time). A look stays until you turn it off or a room is loaded (a restart counts). Turning it off with MOSAIC_NONE hands the slot back at once, but hiding something does not: destroy it, do not hide it. If there is no room for another one, a development build stops with a message that names every look holding a slot; a release build draws everything sharp. The in-game debug overlay shows the count as H-BLANK.

See also: background_blockysprite_blockyscreen_blendscreen_scanlinesbackground_createscreen_backdrop